<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html lang = "en">

<head>

<link rel="shortcut icon" href="http://algs4.cs.princeton.edu/favicon.ico">
<link rel="stylesheet"    href="http://algs4.cs.princeton.edu/java.css" type="text/css">

<title>GaussianElimination.java</title>

<meta HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
<meta NAME="AUTHOR" CONTENT="Robert Sedgewick and Kevin Wayne">
<meta NAME="DESCRIPTION" CONTENT="GaussianElimination code in Java">
<meta NAME="TITLE" CONTENT="GaussianElimination code in Java">
<meta NAME="KEYWORDS" CONTENT="GaussianElimination,java,programming,computer science,algorithm,data structure,program,code">
<meta NAME="ROBOTS" CONTENT="INDEX,FOLLOW">

</head>


<body>
<center><h1>GaussianElimination.java</h1></center><p><br>

Below is the syntax highlighted version of <a href = "GaussianElimination.java">GaussianElimination.java</a>.
<p><br>

<!-- Generator: GNU source-highlight 3.1.6
by Lorenzo Bettini
http://www.lorenzobettini.it
http://www.gnu.org/software/src-highlite -->
<pre><tt><span class="comment">/******************************************************************************</span>
<span class="comment"> *  Compilation:  javac GaussianElimination.java</span>
<span class="comment"> *  Execution:    java GaussianElimination M N</span>
<span class="comment"> *  Dependencies: StdOut.java</span>
<span class="comment"> * </span>
<span class="comment"> *  Gaussian elimination with partial pivoting for M-by-N system.</span>
<span class="comment"> *</span>
<span class="comment"> *  % java GaussianElimination M N</span>
<span class="comment"> *  -1.000000</span>
<span class="comment"> *  2.000000</span>
<span class="comment"> *  2.000000</span>
<span class="comment"> *</span>
<span class="comment"> *  3.000000</span>
<span class="comment"> *  -1.000000</span>
<span class="comment"> *  -2.000000</span>
<span class="comment"> * </span>
<span class="comment"> *  System is infeasible</span>
<span class="comment"> *</span>
<span class="comment"> *  -6.250000</span>
<span class="comment"> *  -4.500000</span>
<span class="comment"> *  0.000000</span>
<span class="comment"> *  0.000000</span>
<span class="comment"> *  1.000000</span>
<span class="comment"> *</span>
<span class="comment"> *  System is infeasible</span>
<span class="comment"> *</span>
<span class="comment"> *  -1.375000</span>
<span class="comment"> *  1.625000</span>
<span class="comment"> *  0.000000</span>
<span class="comment"> *</span>
<span class="comment"> ******************************************************************************/</span>

<span class="preproc">package</span><span class="normal"> edu</span><span class="symbol">.</span><span class="normal">princeton</span><span class="symbol">.</span><span class="normal">cs</span><span class="symbol">.</span><span class="normal">algs4</span><span class="symbol">;</span>

<span class="comment">/**</span>
<span class="comment"> *  The </span><span class="keyword">&lt;tt&gt;</span><span class="comment">GaussianElimination</span><span class="keyword">&lt;/tt&gt;</span><span class="comment"> data type provides methods</span>
<span class="comment"> *  to solve a linear system of equations </span><span class="keyword">&lt;em&gt;</span><span class="comment">Ax</span><span class="keyword">&lt;/em&gt;</span><span class="comment"> = </span><span class="keyword">&lt;em&gt;</span><span class="comment">b</span><span class="keyword">&lt;/em&gt;</span><span class="comment">,</span>
<span class="comment"> *  where </span><span class="keyword">&lt;em&gt;</span><span class="comment">A</span><span class="keyword">&lt;/em&gt;</span><span class="comment"> is an </span><span class="keyword">&lt;em&gt;</span><span class="comment">M</span><span class="keyword">&lt;/em&gt;</span><span class="comment">-by-</span><span class="keyword">&lt;em&gt;</span><span class="comment">N</span><span class="keyword">&lt;/em&gt;</span><span class="comment"> matrix</span>
<span class="comment"> *  and </span><span class="keyword">&lt;em&gt;</span><span class="comment">b</span><span class="keyword">&lt;/em&gt;</span><span class="comment"> is a length </span><span class="keyword">&lt;em&gt;</span><span class="comment">N</span><span class="keyword">&lt;/em&gt;</span><span class="comment"> vector.</span>
<span class="comment"> *  </span><span class="keyword">&lt;p&gt;</span>
<span class="comment"> *  This is a bare-bones implementation that uses Gaussian elimination</span>
<span class="comment"> *  with partial pivoting.</span>
<span class="comment"> *  See </span><span class="keyword">&lt;a</span><span class="normal"> </span><span class="type">href</span><span class="normal"> </span><span class="symbol">=</span><span class="string"> "http://algs4.cs.princeton.edu/99scientific/GaussianEliminationLite.java.html"</span><span class="keyword">&gt;</span><span class="comment">GaussianEliminationLite.java</span><span class="keyword">&lt;/a&gt;</span>
<span class="comment"> *  for a stripped-down version that assumes the matrix </span><span class="keyword">&lt;em&gt;</span><span class="comment">A</span><span class="keyword">&lt;/em&gt;</span><span class="comment"> is square</span>
<span class="comment"> *  and nonsingular. See {</span><span class="type">@link</span><span class="comment"> GaussJordanElimination} for an alternate</span>
<span class="comment"> *  implementation that uses Gauss-Jordan elimination.</span>
<span class="comment"> *  For an industrial-strength numerical linear algebra library,</span>
<span class="comment"> *  see </span><span class="keyword">&lt;a</span><span class="normal"> </span><span class="type">href</span><span class="normal"> </span><span class="symbol">=</span><span class="string"> "http://math.nist.gov/javanumerics/jama/"</span><span class="keyword">&gt;</span><span class="comment">JAMA</span><span class="keyword">&lt;/a&gt;</span><span class="comment">.</span>
<span class="comment"> *  </span><span class="keyword">&lt;p&gt;</span>
<span class="comment"> *  For additional documentation, see</span>
<span class="comment"> *  </span><span class="keyword">&lt;a</span><span class="normal"> </span><span class="type">href</span><span class="symbol">=</span><span class="string">"http://algs4.cs.princeton.edu/99scientific"</span><span class="keyword">&gt;</span><span class="comment">Section 9.9</span><span class="keyword">&lt;/a&gt;</span>
<span class="comment"> *  </span><span class="keyword">&lt;i&gt;</span><span class="comment">Algorithms, 4th Edition</span><span class="keyword">&lt;/i&gt;</span><span class="comment"> by Robert Sedgewick and Kevin Wayne.</span>
<span class="comment"> *</span>
<span class="comment"> *  </span><span class="type">@author</span><span class="comment"> Robert Sedgewick</span>
<span class="comment"> *  </span><span class="type">@author</span><span class="comment"> Kevin Wayne</span>
<span class="comment"> */</span>
<span class="keyword">public</span><span class="normal"> </span><span class="keyword">class</span><span class="normal"> </span><span class="classname">GaussianElimination</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="keyword">static</span><span class="normal"> </span><span class="keyword">final</span><span class="normal"> </span><span class="type">double</span><span class="normal"> EPSILON </span><span class="symbol">=</span><span class="normal"> </span><span class="number">1e-8</span><span class="symbol">;</span>

<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="keyword">final</span><span class="normal"> </span><span class="type">int</span><span class="normal"> M</span><span class="symbol">;</span><span class="normal">      </span><span class="comment">// number of rows</span>
<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="keyword">final</span><span class="normal"> </span><span class="type">int</span><span class="normal"> N</span><span class="symbol">;</span><span class="normal">      </span><span class="comment">// number of columns</span>
<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="type">double</span><span class="symbol">[][]</span><span class="normal"> a</span><span class="symbol">;</span><span class="normal">     </span><span class="comment">// M-by-N+1 augmented matrix</span>

<span class="normal">    </span><span class="comment">/**</span>
<span class="comment">     * Solves the linear system of equations </span><span class="keyword">&lt;em&gt;</span><span class="comment">Ax</span><span class="keyword">&lt;/em&gt;</span><span class="comment"> = </span><span class="keyword">&lt;em&gt;</span><span class="comment">b</span><span class="keyword">&lt;/em&gt;</span><span class="comment">,</span>
<span class="comment">     * where </span><span class="keyword">&lt;em&gt;</span><span class="comment">A</span><span class="keyword">&lt;/em&gt;</span><span class="comment"> is an </span><span class="keyword">&lt;em&gt;</span><span class="comment">M</span><span class="keyword">&lt;/em&gt;</span><span class="comment">-by-</span><span class="keyword">&lt;em&gt;</span><span class="comment">N</span><span class="keyword">&lt;/em&gt;</span><span class="comment"> matrix and </span><span class="keyword">&lt;em&gt;</span><span class="comment">b</span><span class="keyword">&lt;/em&gt;</span>
<span class="comment">     * is a length </span><span class="keyword">&lt;em&gt;</span><span class="comment">M</span><span class="keyword">&lt;/em&gt;</span><span class="comment"> vector.</span>
<span class="comment">     *</span>
<span class="comment">     * </span><span class="type">@param</span><span class="comment">  A the </span><span class="keyword">&lt;em&gt;</span><span class="comment">M</span><span class="keyword">&lt;/em&gt;</span><span class="comment">-by-</span><span class="keyword">&lt;em&gt;</span><span class="comment">N</span><span class="keyword">&lt;/em&gt;</span><span class="comment"> constraint matrix</span>
<span class="comment">     * </span><span class="type">@param</span><span class="comment">  b the length </span><span class="keyword">&lt;em&gt;</span><span class="comment">M</span><span class="keyword">&lt;/em&gt;</span><span class="comment"> right-hand-side vector</span>
<span class="comment">     * </span><span class="type">@throws</span><span class="comment"> IllegalArgumentException if the dimensions disagree, i.e.,</span>
<span class="comment">     *         the length of </span><span class="keyword">&lt;tt&gt;</span><span class="comment">b</span><span class="keyword">&lt;/tt&gt;</span><span class="comment"> does not equal </span><span class="keyword">&lt;tt&gt;</span><span class="comment">M</span><span class="keyword">&lt;/tt&gt;</span>
<span class="comment">     */</span>
<span class="normal">    </span><span class="keyword">public</span><span class="normal"> </span><span class="function">GaussianElimination</span><span class="symbol">(</span><span class="type">double</span><span class="symbol">[][]</span><span class="normal"> A</span><span class="symbol">,</span><span class="normal"> </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> b</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        M </span><span class="symbol">=</span><span class="normal"> A</span><span class="symbol">.</span><span class="normal">length</span><span class="symbol">;</span>
<span class="normal">        N </span><span class="symbol">=</span><span class="normal"> A</span><span class="symbol">[</span><span class="number">0</span><span class="symbol">].</span><span class="normal">length</span><span class="symbol">;</span>

<span class="normal">        </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">b</span><span class="symbol">.</span><span class="normal">length </span><span class="symbol">!=</span><span class="normal"> M</span><span class="symbol">)</span><span class="normal"> </span><span class="keyword">throw</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> </span><span class="function">IllegalArgumentException</span><span class="symbol">(</span><span class="string">"Dimensions disagree"</span><span class="symbol">);</span>

<span class="normal">        </span><span class="comment">// build augmented matrix</span>
<span class="normal">        a </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> </span><span class="type">double</span><span class="symbol">[</span><span class="normal">M</span><span class="symbol">][</span><span class="normal">N</span><span class="symbol">+</span><span class="number">1</span><span class="symbol">];</span>
<span class="normal">        </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> i </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> i </span><span class="symbol">&lt;</span><span class="normal"> M</span><span class="symbol">;</span><span class="normal"> i</span><span class="symbol">++)</span>
<span class="normal">            </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> j </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> j </span><span class="symbol">&lt;</span><span class="normal"> N</span><span class="symbol">;</span><span class="normal"> j</span><span class="symbol">++)</span>
<span class="normal">                a</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">][</span><span class="normal">j</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> A</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">][</span><span class="normal">j</span><span class="symbol">];</span>
<span class="normal">        </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> i </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> i </span><span class="symbol">&lt;</span><span class="normal"> M</span><span class="symbol">;</span><span class="normal"> i</span><span class="symbol">++)</span>
<span class="normal">            a</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">][</span><span class="normal">N</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> b</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">];</span>

<span class="normal">        </span><span class="function">forwardElimination</span><span class="symbol">();</span>

<span class="normal">        </span><span class="keyword">assert</span><span class="normal"> </span><span class="function">certifySolution</span><span class="symbol">(</span><span class="normal">A</span><span class="symbol">,</span><span class="normal"> b</span><span class="symbol">);</span>
<span class="normal">    </span><span class="cbracket">}</span>

<span class="normal">    </span><span class="comment">// forward elimination</span>
<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">forwardElimination</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> p </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> p </span><span class="symbol">&lt;</span><span class="normal"> Math</span><span class="symbol">.</span><span class="function">min</span><span class="symbol">(</span><span class="normal">M</span><span class="symbol">,</span><span class="normal"> N</span><span class="symbol">);</span><span class="normal"> p</span><span class="symbol">++)</span><span class="normal"> </span><span class="cbracket">{</span>

<span class="normal">            </span><span class="comment">// find pivot row using partial pivoting</span>
<span class="normal">            </span><span class="type">int</span><span class="normal"> max </span><span class="symbol">=</span><span class="normal"> p</span><span class="symbol">;</span>
<span class="normal">            </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> i </span><span class="symbol">=</span><span class="normal"> p</span><span class="symbol">+</span><span class="number">1</span><span class="symbol">;</span><span class="normal"> i </span><span class="symbol">&lt;</span><span class="normal"> M</span><span class="symbol">;</span><span class="normal"> i</span><span class="symbol">++)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">                </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">Math</span><span class="symbol">.</span><span class="function">abs</span><span class="symbol">(</span><span class="normal">a</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">][</span><span class="normal">p</span><span class="symbol">])</span><span class="normal"> </span><span class="symbol">&gt;</span><span class="normal"> Math</span><span class="symbol">.</span><span class="function">abs</span><span class="symbol">(</span><span class="normal">a</span><span class="symbol">[</span><span class="normal">max</span><span class="symbol">][</span><span class="normal">p</span><span class="symbol">]))</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">                    max </span><span class="symbol">=</span><span class="normal"> i</span><span class="symbol">;</span>
<span class="normal">                </span><span class="cbracket">}</span>
<span class="normal">            </span><span class="cbracket">}</span>

<span class="normal">            </span><span class="comment">// swap</span>
<span class="normal">            </span><span class="function">swap</span><span class="symbol">(</span><span class="normal">p</span><span class="symbol">,</span><span class="normal"> max</span><span class="symbol">);</span>

<span class="normal">            </span><span class="comment">// singular or nearly singular</span>
<span class="normal">            </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">Math</span><span class="symbol">.</span><span class="function">abs</span><span class="symbol">(</span><span class="normal">a</span><span class="symbol">[</span><span class="normal">p</span><span class="symbol">][</span><span class="normal">p</span><span class="symbol">])</span><span class="normal"> </span><span class="symbol">&lt;=</span><span class="normal"> EPSILON</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">                </span><span class="keyword">continue</span><span class="symbol">;</span>
<span class="normal">            </span><span class="cbracket">}</span>

<span class="normal">            </span><span class="comment">// pivot</span>
<span class="normal">            </span><span class="function">pivot</span><span class="symbol">(</span><span class="normal">p</span><span class="symbol">);</span>
<span class="normal">        </span><span class="cbracket">}</span>
<span class="normal">    </span><span class="cbracket">}</span>

<span class="normal">    </span><span class="comment">// swap row1 and row2</span>
<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">swap</span><span class="symbol">(</span><span class="type">int</span><span class="normal"> row1</span><span class="symbol">,</span><span class="normal"> </span><span class="type">int</span><span class="normal"> row2</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> temp </span><span class="symbol">=</span><span class="normal"> a</span><span class="symbol">[</span><span class="normal">row1</span><span class="symbol">];</span>
<span class="normal">        a</span><span class="symbol">[</span><span class="normal">row1</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> a</span><span class="symbol">[</span><span class="normal">row2</span><span class="symbol">];</span>
<span class="normal">        a</span><span class="symbol">[</span><span class="normal">row2</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> temp</span><span class="symbol">;</span>
<span class="normal">    </span><span class="cbracket">}</span>

<span class="normal">    </span><span class="comment">// pivot on a[p][p]</span>
<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">pivot</span><span class="symbol">(</span><span class="type">int</span><span class="normal"> p</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> i </span><span class="symbol">=</span><span class="normal"> p</span><span class="symbol">+</span><span class="number">1</span><span class="symbol">;</span><span class="normal"> i </span><span class="symbol">&lt;</span><span class="normal"> M</span><span class="symbol">;</span><span class="normal"> i</span><span class="symbol">++)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">            </span><span class="type">double</span><span class="normal"> alpha </span><span class="symbol">=</span><span class="normal"> a</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">][</span><span class="normal">p</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">/</span><span class="normal"> a</span><span class="symbol">[</span><span class="normal">p</span><span class="symbol">][</span><span class="normal">p</span><span class="symbol">];</span>
<span class="normal">            </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> j </span><span class="symbol">=</span><span class="normal"> p</span><span class="symbol">;</span><span class="normal"> j </span><span class="symbol">&lt;=</span><span class="normal"> N</span><span class="symbol">;</span><span class="normal"> j</span><span class="symbol">++)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">                a</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">][</span><span class="normal">j</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">-=</span><span class="normal"> alpha </span><span class="symbol">*</span><span class="normal"> a</span><span class="symbol">[</span><span class="normal">p</span><span class="symbol">][</span><span class="normal">j</span><span class="symbol">];</span>
<span class="normal">            </span><span class="cbracket">}</span>
<span class="normal">        </span><span class="cbracket">}</span>
<span class="normal">    </span><span class="cbracket">}</span>

<span class="normal">    </span><span class="comment">/**</span>
<span class="comment">     * Returns a solution to the linear system of equations </span><span class="keyword">&lt;em&gt;</span><span class="comment">Ax</span><span class="keyword">&lt;/em&gt;</span><span class="comment"> = </span><span class="keyword">&lt;em&gt;</span><span class="comment">b</span><span class="keyword">&lt;/em&gt;</span><span class="comment">.</span>
<span class="comment">     *      </span>
<span class="comment">     * </span><span class="type">@return</span><span class="comment"> a solution </span><span class="keyword">&lt;em&gt;</span><span class="comment">x</span><span class="keyword">&lt;/em&gt;</span><span class="comment"> to the linear system of equations</span>
<span class="comment">     *         </span><span class="keyword">&lt;em&gt;</span><span class="comment">Ax</span><span class="keyword">&lt;/em&gt;</span><span class="comment"> = </span><span class="keyword">&lt;em&gt;</span><span class="comment">b</span><span class="keyword">&lt;/em&gt;</span><span class="comment">; </span><span class="keyword">&lt;tt&gt;</span><span class="comment">null</span><span class="keyword">&lt;/tt&gt;</span><span class="comment"> if no such solution</span>
<span class="comment">     */</span>
<span class="normal">    </span><span class="keyword">public</span><span class="normal"> </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> </span><span class="function">primal</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        </span><span class="comment">// back substitution</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> x </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> </span><span class="type">double</span><span class="symbol">[</span><span class="normal">N</span><span class="symbol">];</span>
<span class="normal">        </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> i </span><span class="symbol">=</span><span class="normal"> Math</span><span class="symbol">.</span><span class="function">min</span><span class="symbol">(</span><span class="normal">N</span><span class="symbol">-</span><span class="number">1</span><span class="symbol">,</span><span class="normal"> M</span><span class="symbol">-</span><span class="number">1</span><span class="symbol">);</span><span class="normal"> i </span><span class="symbol">&gt;=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> i</span><span class="symbol">--)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">            </span><span class="type">double</span><span class="normal"> sum </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0.0</span><span class="symbol">;</span>
<span class="normal">            </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> j </span><span class="symbol">=</span><span class="normal"> i</span><span class="symbol">+</span><span class="number">1</span><span class="symbol">;</span><span class="normal"> j </span><span class="symbol">&lt;</span><span class="normal"> N</span><span class="symbol">;</span><span class="normal"> j</span><span class="symbol">++)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">                sum </span><span class="symbol">+=</span><span class="normal"> a</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">][</span><span class="normal">j</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">*</span><span class="normal"> x</span><span class="symbol">[</span><span class="normal">j</span><span class="symbol">];</span>
<span class="normal">            </span><span class="cbracket">}</span>

<span class="normal">            </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">Math</span><span class="symbol">.</span><span class="function">abs</span><span class="symbol">(</span><span class="normal">a</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">][</span><span class="normal">i</span><span class="symbol">])</span><span class="normal"> </span><span class="symbol">&gt;</span><span class="normal"> EPSILON</span><span class="symbol">)</span>
<span class="normal">                x</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">a</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">][</span><span class="normal">N</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">-</span><span class="normal"> sum</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">/</span><span class="normal"> a</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">][</span><span class="normal">i</span><span class="symbol">];</span>
<span class="normal">            </span><span class="keyword">else</span><span class="normal"> </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">Math</span><span class="symbol">.</span><span class="function">abs</span><span class="symbol">(</span><span class="normal">a</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">][</span><span class="normal">N</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">-</span><span class="normal"> sum</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">&gt;</span><span class="normal"> EPSILON</span><span class="symbol">)</span>
<span class="normal">                </span><span class="keyword">return</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">;</span>
<span class="normal">        </span><span class="cbracket">}</span>

<span class="normal">        </span><span class="comment">// redundant rows</span>
<span class="normal">        </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> i </span><span class="symbol">=</span><span class="normal"> N</span><span class="symbol">;</span><span class="normal"> i </span><span class="symbol">&lt;</span><span class="normal"> M</span><span class="symbol">;</span><span class="normal"> i</span><span class="symbol">++)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">            </span><span class="type">double</span><span class="normal"> sum </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0.0</span><span class="symbol">;</span>
<span class="normal">            </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> j </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> j </span><span class="symbol">&lt;</span><span class="normal"> N</span><span class="symbol">;</span><span class="normal"> j</span><span class="symbol">++)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">                sum </span><span class="symbol">+=</span><span class="normal"> a</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">][</span><span class="normal">j</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">*</span><span class="normal"> x</span><span class="symbol">[</span><span class="normal">j</span><span class="symbol">];</span>
<span class="normal">            </span><span class="cbracket">}</span>
<span class="normal">            </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">Math</span><span class="symbol">.</span><span class="function">abs</span><span class="symbol">(</span><span class="normal">a</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">][</span><span class="normal">N</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">-</span><span class="normal"> sum</span><span class="symbol">)</span><span class="normal"> </span><span class="symbol">&gt;</span><span class="normal"> EPSILON</span><span class="symbol">)</span>
<span class="normal">                </span><span class="keyword">return</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">;</span>
<span class="normal">        </span><span class="cbracket">}</span>
<span class="normal">        </span><span class="keyword">return</span><span class="normal"> x</span><span class="symbol">;</span>
<span class="normal">    </span><span class="cbracket">}</span>

<span class="normal">    </span><span class="comment">/**</span>
<span class="comment">     * Returns true if there exists a solution to the linear system of</span>
<span class="comment">     * equations </span><span class="keyword">&lt;em&gt;</span><span class="comment">Ax</span><span class="keyword">&lt;/em&gt;</span><span class="comment"> = </span><span class="keyword">&lt;em&gt;</span><span class="comment">b</span><span class="keyword">&lt;/em&gt;</span><span class="comment">.</span>
<span class="comment">     *      </span>
<span class="comment">     * </span><span class="type">@return</span><span class="comment"> </span><span class="keyword">&lt;tt&gt;</span><span class="comment">true</span><span class="keyword">&lt;/tt&gt;</span><span class="comment"> if there exists a solution to the linear system</span>
<span class="comment">     *         of equations </span><span class="keyword">&lt;em&gt;</span><span class="comment">Ax</span><span class="keyword">&lt;/em&gt;</span><span class="comment"> = </span><span class="keyword">&lt;em&gt;</span><span class="comment">b</span><span class="keyword">&lt;/em&gt;</span><span class="comment">; </span><span class="keyword">&lt;tt&gt;</span><span class="comment">false</span><span class="keyword">&lt;/tt&gt;</span><span class="comment"> otherwise</span>
<span class="comment">     */</span>
<span class="normal">    </span><span class="keyword">public</span><span class="normal"> </span><span class="type">boolean</span><span class="normal"> </span><span class="function">isFeasible</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        </span><span class="keyword">return</span><span class="normal"> </span><span class="function">primal</span><span class="symbol">()</span><span class="normal"> </span><span class="symbol">!=</span><span class="normal"> </span><span class="keyword">null</span><span class="symbol">;</span>
<span class="normal">    </span><span class="cbracket">}</span>


<span class="normal">    </span><span class="comment">// check that Ax = b</span>
<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="type">boolean</span><span class="normal"> </span><span class="function">certifySolution</span><span class="symbol">(</span><span class="type">double</span><span class="symbol">[][]</span><span class="normal"> A</span><span class="symbol">,</span><span class="normal"> </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> b</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(!</span><span class="function">isFeasible</span><span class="symbol">())</span><span class="normal"> </span><span class="keyword">return</span><span class="normal"> </span><span class="keyword">true</span><span class="symbol">;</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> x </span><span class="symbol">=</span><span class="normal"> </span><span class="function">primal</span><span class="symbol">();</span>
<span class="normal">        </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> i </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> i </span><span class="symbol">&lt;</span><span class="normal"> M</span><span class="symbol">;</span><span class="normal"> i</span><span class="symbol">++)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">            </span><span class="type">double</span><span class="normal"> sum </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0.0</span><span class="symbol">;</span>
<span class="normal">            </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> j </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> j </span><span class="symbol">&lt;</span><span class="normal"> N</span><span class="symbol">;</span><span class="normal"> j</span><span class="symbol">++)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">                sum </span><span class="symbol">+=</span><span class="normal"> A</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">][</span><span class="normal">j</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">*</span><span class="normal"> x</span><span class="symbol">[</span><span class="normal">j</span><span class="symbol">];</span>
<span class="normal">            </span><span class="cbracket">}</span>
<span class="normal">            </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">Math</span><span class="symbol">.</span><span class="function">abs</span><span class="symbol">(</span><span class="normal">sum </span><span class="symbol">-</span><span class="normal"> b</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">])</span><span class="normal"> </span><span class="symbol">&gt;</span><span class="normal"> EPSILON</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">                StdOut</span><span class="symbol">.</span><span class="function">println</span><span class="symbol">(</span><span class="string">"not feasible"</span><span class="symbol">);</span>
<span class="normal">                StdOut</span><span class="symbol">.</span><span class="function">println</span><span class="symbol">(</span><span class="string">"b["</span><span class="normal"> </span><span class="symbol">+</span><span class="normal"> i </span><span class="symbol">+</span><span class="normal"> </span><span class="string">"] = "</span><span class="normal"> </span><span class="symbol">+</span><span class="normal"> b</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">+</span><span class="normal"> </span><span class="string">", sum = "</span><span class="normal"> </span><span class="symbol">+</span><span class="normal"> sum</span><span class="symbol">);</span>
<span class="normal">                </span><span class="keyword">return</span><span class="normal"> </span><span class="keyword">false</span><span class="symbol">;</span>
<span class="normal">            </span><span class="cbracket">}</span>
<span class="normal">        </span><span class="cbracket">}</span>
<span class="normal">        </span><span class="keyword">return</span><span class="normal"> </span><span class="keyword">true</span><span class="symbol">;</span>
<span class="normal">    </span><span class="cbracket">}</span>


<span class="normal">    </span><span class="comment">/**</span>
<span class="comment">     * Unit tests the </span><span class="keyword">&lt;tt&gt;</span><span class="comment">GaussianElimination</span><span class="keyword">&lt;/tt&gt;</span><span class="comment"> data type.</span>
<span class="comment">     */</span>
<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">test</span><span class="symbol">(</span><span class="usertype">String</span><span class="normal"> name</span><span class="symbol">,</span><span class="normal"> </span><span class="type">double</span><span class="symbol">[][]</span><span class="normal"> A</span><span class="symbol">,</span><span class="normal"> </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> b</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        StdOut</span><span class="symbol">.</span><span class="function">println</span><span class="symbol">(</span><span class="string">"----------------------------------------------------"</span><span class="symbol">);</span>
<span class="normal">        StdOut</span><span class="symbol">.</span><span class="function">println</span><span class="symbol">(</span><span class="normal">name</span><span class="symbol">);</span>
<span class="normal">        StdOut</span><span class="symbol">.</span><span class="function">println</span><span class="symbol">(</span><span class="string">"----------------------------------------------------"</span><span class="symbol">);</span>
<span class="normal">        </span><span class="usertype">GaussianElimination</span><span class="normal"> gaussian </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> </span><span class="function">GaussianElimination</span><span class="symbol">(</span><span class="normal">A</span><span class="symbol">,</span><span class="normal"> b</span><span class="symbol">);</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> x </span><span class="symbol">=</span><span class="normal"> gaussian</span><span class="symbol">.</span><span class="function">primal</span><span class="symbol">();</span>
<span class="normal">        </span><span class="keyword">if</span><span class="normal"> </span><span class="symbol">(</span><span class="normal">gaussian</span><span class="symbol">.</span><span class="function">isFeasible</span><span class="symbol">())</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">            </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> i </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> i </span><span class="symbol">&lt;</span><span class="normal"> x</span><span class="symbol">.</span><span class="normal">length</span><span class="symbol">;</span><span class="normal"> i</span><span class="symbol">++)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">                StdOut</span><span class="symbol">.</span><span class="function">printf</span><span class="symbol">(</span><span class="string">"%.6f</span><span class="specialchar">\n</span><span class="string">"</span><span class="symbol">,</span><span class="normal"> x</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">]);</span>
<span class="normal">            </span><span class="cbracket">}</span>
<span class="normal">        </span><span class="cbracket">}</span>
<span class="normal">        </span><span class="keyword">else</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">            StdOut</span><span class="symbol">.</span><span class="function">println</span><span class="symbol">(</span><span class="string">"System is infeasible"</span><span class="symbol">);</span>
<span class="normal">        </span><span class="cbracket">}</span>
<span class="normal">        StdOut</span><span class="symbol">.</span><span class="function">println</span><span class="symbol">();</span>
<span class="normal">        StdOut</span><span class="symbol">.</span><span class="function">println</span><span class="symbol">();</span>
<span class="normal">    </span><span class="cbracket">}</span>


<span class="normal">    </span><span class="comment">// 3-by-3 nonsingular system</span>
<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">test1</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[][]</span><span class="normal"> A </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">0</span><span class="symbol">,</span><span class="normal"> </span><span class="number">1</span><span class="symbol">,</span><span class="normal">  </span><span class="number">1</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">2</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">0</span><span class="symbol">,</span><span class="normal"> </span><span class="number">3</span><span class="symbol">,</span><span class="normal"> </span><span class="number">15</span><span class="normal"> </span><span class="cbracket">}</span>
<span class="normal">        </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> b </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="number">36</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="function">test</span><span class="symbol">(</span><span class="string">"test 1 (3-by-3 system, nonsingular)"</span><span class="symbol">,</span><span class="normal"> A</span><span class="symbol">,</span><span class="normal"> b</span><span class="symbol">);</span>
<span class="normal">    </span><span class="cbracket">}</span>

<span class="normal">    </span><span class="comment">// 3-by-3 nonsingular system</span>
<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">test2</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[][]</span><span class="normal"> A </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal">  </span><span class="number">1</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">3</span><span class="symbol">,</span><span class="normal">   </span><span class="number">1</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal">  </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">8</span><span class="symbol">,</span><span class="normal">   </span><span class="number">8</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal"> </span><span class="symbol">-</span><span class="number">6</span><span class="symbol">,</span><span class="normal">  </span><span class="number">3</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">15</span><span class="normal"> </span><span class="cbracket">}</span>
<span class="normal">        </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> b </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="number">9</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="function">test</span><span class="symbol">(</span><span class="string">"test 2 (3-by-3 system, nonsingular)"</span><span class="symbol">,</span><span class="normal"> A</span><span class="symbol">,</span><span class="normal"> b</span><span class="symbol">);</span>
<span class="normal">    </span><span class="cbracket">}</span>

<span class="normal">    </span><span class="comment">// 5-by-5 singular: no solutions</span>
<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">test3</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[][]</span><span class="normal"> A </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal">  </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">3</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">1</span><span class="symbol">,</span><span class="normal">  </span><span class="number">2</span><span class="symbol">,</span><span class="normal">  </span><span class="number">3</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal">  </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">1</span><span class="symbol">,</span><span class="normal">  </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="number">11</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal">  </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">5</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">2</span><span class="symbol">,</span><span class="normal">  </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">1</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal">  </span><span class="number">0</span><span class="symbol">,</span><span class="normal">  </span><span class="number">2</span><span class="symbol">,</span><span class="normal">  </span><span class="number">1</span><span class="symbol">,</span><span class="normal">  </span><span class="number">0</span><span class="symbol">,</span><span class="normal">  </span><span class="number">4</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal"> </span><span class="symbol">-</span><span class="number">4</span><span class="symbol">,</span><span class="normal">  </span><span class="number">6</span><span class="symbol">,</span><span class="normal">  </span><span class="number">0</span><span class="symbol">,</span><span class="normal">  </span><span class="number">0</span><span class="symbol">,</span><span class="normal">  </span><span class="number">7</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">        </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> b </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="number">9</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">6</span><span class="symbol">,</span><span class="normal"> </span><span class="number">5</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="function">test</span><span class="symbol">(</span><span class="string">"test 3 (5-by-5 system, no solutions)"</span><span class="symbol">,</span><span class="normal"> A</span><span class="symbol">,</span><span class="normal"> b</span><span class="symbol">);</span>
<span class="normal">    </span><span class="cbracket">}</span>

<span class="normal">    </span><span class="comment">// 5-by-5 singular: infinitely many solutions</span>
<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">test4</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[][]</span><span class="normal"> A </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal">  </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">3</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">1</span><span class="symbol">,</span><span class="normal">  </span><span class="number">2</span><span class="symbol">,</span><span class="normal">  </span><span class="number">3</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal">  </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">1</span><span class="symbol">,</span><span class="normal">  </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="number">11</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal">  </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">5</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">2</span><span class="symbol">,</span><span class="normal">  </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">1</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal">  </span><span class="number">0</span><span class="symbol">,</span><span class="normal">  </span><span class="number">2</span><span class="symbol">,</span><span class="normal">  </span><span class="number">1</span><span class="symbol">,</span><span class="normal">  </span><span class="number">0</span><span class="symbol">,</span><span class="normal">  </span><span class="number">4</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal"> </span><span class="symbol">-</span><span class="number">4</span><span class="symbol">,</span><span class="normal">  </span><span class="number">6</span><span class="symbol">,</span><span class="normal">  </span><span class="number">0</span><span class="symbol">,</span><span class="normal">  </span><span class="number">0</span><span class="symbol">,</span><span class="normal">  </span><span class="number">7</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">        </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> b </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="number">9</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">5</span><span class="symbol">,</span><span class="normal"> </span><span class="number">5</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="function">test</span><span class="symbol">(</span><span class="string">"test 4 (5-by-5 system, infinitely many solutions)"</span><span class="symbol">,</span><span class="normal"> A</span><span class="symbol">,</span><span class="normal"> b</span><span class="symbol">);</span>
<span class="normal">    </span><span class="cbracket">}</span>

<span class="normal">    </span><span class="comment">// 3-by-3 singular: no solutions</span>
<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">test5</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[][]</span><span class="normal"> A </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal">  </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">1</span><span class="symbol">,</span><span class="normal">  </span><span class="number">1</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal">  </span><span class="number">3</span><span class="symbol">,</span><span class="normal">  </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">4</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal"> </span><span class="symbol">-</span><span class="number">6</span><span class="symbol">,</span><span class="normal">  </span><span class="number">3</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">3</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">        </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> b </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">1</span><span class="symbol">,</span><span class="normal"> </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="number">2</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="function">test</span><span class="symbol">(</span><span class="string">"test 5 (3-by-3 system, no solutions)"</span><span class="symbol">,</span><span class="normal"> A</span><span class="symbol">,</span><span class="normal"> b</span><span class="symbol">);</span>
<span class="normal">    </span><span class="cbracket">}</span>

<span class="normal">    </span><span class="comment">// 3-by-3 singular: infinitely many solutions</span>
<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">test6</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[][]</span><span class="normal"> A </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal">  </span><span class="number">1</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">1</span><span class="symbol">,</span><span class="normal">  </span><span class="number">2</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal">  </span><span class="number">4</span><span class="symbol">,</span><span class="normal">  </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">2</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal"> </span><span class="symbol">-</span><span class="number">2</span><span class="symbol">,</span><span class="normal">  </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">4</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">        </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> b </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span><span class="normal"> </span><span class="symbol">-</span><span class="number">3</span><span class="symbol">,</span><span class="normal"> </span><span class="number">1</span><span class="symbol">,</span><span class="normal"> </span><span class="number">6</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="function">test</span><span class="symbol">(</span><span class="string">"test 6 (3-by-3 system, infinitely many solutions)"</span><span class="symbol">,</span><span class="normal"> A</span><span class="symbol">,</span><span class="normal"> b</span><span class="symbol">);</span>
<span class="normal">    </span><span class="cbracket">}</span>

<span class="normal">    </span><span class="comment">// 4-by-3 full rank and feasible system</span>
<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">test7</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[][]</span><span class="normal"> A </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">0</span><span class="symbol">,</span><span class="normal"> </span><span class="number">1</span><span class="symbol">,</span><span class="normal">  </span><span class="number">1</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">2</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">0</span><span class="symbol">,</span><span class="normal"> </span><span class="number">3</span><span class="symbol">,</span><span class="normal"> </span><span class="number">15</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="number">8</span><span class="symbol">,</span><span class="normal"> </span><span class="number">14</span><span class="normal"> </span><span class="cbracket">}</span>
<span class="normal">        </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> b </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="number">36</span><span class="symbol">,</span><span class="normal"> </span><span class="number">42</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="function">test</span><span class="symbol">(</span><span class="string">"test 7 (4-by-3 system, full rank)"</span><span class="symbol">,</span><span class="normal"> A</span><span class="symbol">,</span><span class="normal"> b</span><span class="symbol">);</span>
<span class="normal">    </span><span class="cbracket">}</span>

<span class="normal">    </span><span class="comment">// 4-by-3 full rank and infeasible system</span>
<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">test8</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[][]</span><span class="normal"> A </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">0</span><span class="symbol">,</span><span class="normal"> </span><span class="number">1</span><span class="symbol">,</span><span class="normal">  </span><span class="number">1</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">2</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">0</span><span class="symbol">,</span><span class="normal"> </span><span class="number">3</span><span class="symbol">,</span><span class="normal"> </span><span class="number">15</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="number">8</span><span class="symbol">,</span><span class="normal"> </span><span class="number">14</span><span class="normal"> </span><span class="cbracket">}</span>
<span class="normal">        </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> b </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="number">36</span><span class="symbol">,</span><span class="normal"> </span><span class="number">40</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="function">test</span><span class="symbol">(</span><span class="string">"test 8 (4-by-3 system, no solution)"</span><span class="symbol">,</span><span class="normal"> A</span><span class="symbol">,</span><span class="normal"> b</span><span class="symbol">);</span>
<span class="normal">    </span><span class="cbracket">}</span>

<span class="normal">    </span><span class="comment">// 3-by-4 full rank system</span>
<span class="normal">    </span><span class="keyword">private</span><span class="normal"> </span><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">test9</span><span class="symbol">()</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[][]</span><span class="normal"> A </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal">  </span><span class="number">1</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">3</span><span class="symbol">,</span><span class="normal">   </span><span class="number">1</span><span class="symbol">,</span><span class="normal">  </span><span class="number">1</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal">  </span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">8</span><span class="symbol">,</span><span class="normal">   </span><span class="number">8</span><span class="symbol">,</span><span class="normal">  </span><span class="number">2</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">,</span>
<span class="normal">            </span><span class="cbracket">{</span><span class="normal"> </span><span class="symbol">-</span><span class="number">6</span><span class="symbol">,</span><span class="normal">  </span><span class="number">3</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">15</span><span class="symbol">,</span><span class="normal">  </span><span class="number">3</span><span class="normal"> </span><span class="cbracket">}</span>
<span class="normal">        </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> b </span><span class="symbol">=</span><span class="normal"> </span><span class="cbracket">{</span><span class="normal"> </span><span class="number">4</span><span class="symbol">,</span><span class="normal"> </span><span class="symbol">-</span><span class="number">2</span><span class="symbol">,</span><span class="normal"> </span><span class="number">9</span><span class="normal"> </span><span class="cbracket">}</span><span class="symbol">;</span>
<span class="normal">        </span><span class="function">test</span><span class="symbol">(</span><span class="string">"test 9 (3-by-4 system, full rank)"</span><span class="symbol">,</span><span class="normal"> A</span><span class="symbol">,</span><span class="normal"> b</span><span class="symbol">);</span>
<span class="normal">    </span><span class="cbracket">}</span>

<span class="normal">    </span><span class="comment">/**</span>
<span class="comment">     * Unit tests the </span><span class="keyword">&lt;tt&gt;</span><span class="comment">GaussianElimination</span><span class="keyword">&lt;/tt&gt;</span><span class="comment"> data type.</span>
<span class="comment">     */</span>
<span class="normal">    </span><span class="keyword">public</span><span class="normal"> </span><span class="keyword">static</span><span class="normal"> </span><span class="type">void</span><span class="normal"> </span><span class="function">main</span><span class="symbol">(</span><span class="normal">String</span><span class="symbol">[]</span><span class="normal"> args</span><span class="symbol">)</span><span class="normal"> </span><span class="cbracket">{</span>
<span class="normal">        </span><span class="function">test1</span><span class="symbol">();</span>
<span class="normal">        </span><span class="function">test2</span><span class="symbol">();</span>
<span class="normal">        </span><span class="function">test3</span><span class="symbol">();</span>
<span class="normal">        </span><span class="function">test4</span><span class="symbol">();</span>
<span class="normal">        </span><span class="function">test5</span><span class="symbol">();</span>
<span class="normal">        </span><span class="function">test6</span><span class="symbol">();</span>
<span class="normal">        </span><span class="function">test7</span><span class="symbol">();</span>
<span class="normal">        </span><span class="function">test8</span><span class="symbol">();</span>
<span class="normal">        </span><span class="function">test9</span><span class="symbol">();</span>

<span class="normal">        </span><span class="comment">// N-by-N random system</span>
<span class="normal">        </span><span class="type">int</span><span class="normal"> N </span><span class="symbol">=</span><span class="normal"> Integer</span><span class="symbol">.</span><span class="function">parseInt</span><span class="symbol">(</span><span class="normal">args</span><span class="symbol">[</span><span class="number">0</span><span class="symbol">]);</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[][]</span><span class="normal"> A </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> </span><span class="type">double</span><span class="symbol">[</span><span class="normal">N</span><span class="symbol">][</span><span class="normal">N</span><span class="symbol">];</span>
<span class="normal">        </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> i </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> i </span><span class="symbol">&lt;</span><span class="normal"> N</span><span class="symbol">;</span><span class="normal"> i</span><span class="symbol">++)</span>
<span class="normal">            </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> j </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> j </span><span class="symbol">&lt;</span><span class="normal"> N</span><span class="symbol">;</span><span class="normal"> j</span><span class="symbol">++)</span>
<span class="normal">                A</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">][</span><span class="normal">j</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> StdRandom</span><span class="symbol">.</span><span class="function">uniform</span><span class="symbol">(</span><span class="number">1000</span><span class="symbol">);</span>
<span class="normal">        </span><span class="type">double</span><span class="symbol">[]</span><span class="normal"> b </span><span class="symbol">=</span><span class="normal"> </span><span class="keyword">new</span><span class="normal"> </span><span class="type">double</span><span class="symbol">[</span><span class="normal">N</span><span class="symbol">];</span>
<span class="normal">        </span><span class="keyword">for</span><span class="normal"> </span><span class="symbol">(</span><span class="type">int</span><span class="normal"> i </span><span class="symbol">=</span><span class="normal"> </span><span class="number">0</span><span class="symbol">;</span><span class="normal"> i </span><span class="symbol">&lt;</span><span class="normal"> N</span><span class="symbol">;</span><span class="normal"> i</span><span class="symbol">++)</span>
<span class="normal">            b</span><span class="symbol">[</span><span class="normal">i</span><span class="symbol">]</span><span class="normal"> </span><span class="symbol">=</span><span class="normal"> StdRandom</span><span class="symbol">.</span><span class="function">uniform</span><span class="symbol">(</span><span class="number">1000</span><span class="symbol">);</span>

<span class="normal">        </span><span class="function">test</span><span class="symbol">(</span><span class="normal">N </span><span class="symbol">+</span><span class="normal"> </span><span class="string">"-by-"</span><span class="normal"> </span><span class="symbol">+</span><span class="normal"> N </span><span class="symbol">+</span><span class="normal"> </span><span class="string">" (probably nonsingular)"</span><span class="symbol">,</span><span class="normal"> A</span><span class="symbol">,</span><span class="normal"> b</span><span class="symbol">);</span>
<span class="normal">    </span><span class="cbracket">}</span>

<span class="cbracket">}</span>

<span class="comment">/******************************************************************************</span>
<span class="comment"> *  Copyright 2002-2015, Robert Sedgewick and Kevin Wayne.</span>
<span class="comment"> *</span>
<span class="comment"> *  This file is part of algs4.jar, which accompanies the textbook</span>
<span class="comment"> *</span>
<span class="comment"> *      Algorithms, 4th edition by Robert Sedgewick and Kevin Wayne,</span>
<span class="comment"> *      Addison-Wesley Professional, 2011, ISBN 0-321-57351-X.</span>
<span class="comment"> *      </span><span class="url">http://algs4.cs.princeton.edu</span>
<span class="comment"> *</span>
<span class="comment"> *</span>
<span class="comment"> *  algs4.jar is free software: you can redistribute it and/or modify</span>
<span class="comment"> *  it under the terms of the GNU General Public License as published by</span>
<span class="comment"> *  the Free Software Foundation, either version 3 of the License, or</span>
<span class="comment"> *  (at your option) any later version.</span>
<span class="comment"> *</span>
<span class="comment"> *  algs4.jar is distributed in the hope that it will be useful,</span>
<span class="comment"> *  but WITHOUT ANY WARRANTY; without even the implied warranty of</span>
<span class="comment"> *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the</span>
<span class="comment"> *  GNU General Public License for more details.</span>
<span class="comment"> *</span>
<span class="comment"> *  You should have received a copy of the GNU General Public License</span>
<span class="comment"> *  along with algs4.jar.  If not, see </span><span class="url">http://www.gnu.org/licenses.</span>
<span class="comment"> ******************************************************************************/</span>
</tt></pre>

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try {
var pageTracker = _gat._getTracker("UA-10811519-2");
pageTracker._trackPageview();
} catch(err) {}</script>

</body>

<p><br><address><small>
Last updated: Mon Mar 21 10:51:08 EDT 2016.
</small></address>

</html>
